package com.yc.supermarket.service.impl;

import com.yc.supermarket.entity.Sales;
import com.yc.supermarket.entity.Transaction;
import com.yc.supermarket.mapper.SalesMapper;
import com.yc.supermarket.mapper.TransactionMapper;
import com.yc.supermarket.service.SalesService;
import com.yc.supermarket.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SalesServiceImpl implements SalesService {

    private SalesMapper mapper;

    @Override
    public Map<String,Object> finds(Sales ordertail){
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(SalesMapper.class);
        List<Sales> list=mapper.finds(ordertail);
        System.out.println("the list"+list);
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("data",list);
        return map;
    }

    @Override
    public Map<String,Object> findOne(Transaction order){
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(SalesMapper.class);
        List<Transaction> list=mapper.findOne(order);
        System.out.println("the list"+list);
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("data",list);
        return map;
    }

    @Override
    public Map<String,Object> findAll(Transaction order){
        SqlSession session= MybatisUtil.getSession();
        mapper=session.getMapper(SalesMapper.class);
        List<Transaction> list=mapper.findAll();
        System.out.println("the list"+list);
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("data",list);
        return map;
    }
}
